package com.glsc.ngateway.common.base.domain.mysql.gateway.other;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "t_am_message")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class Message {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id",columnDefinition = "INT(11) COMMENT 'ID'")
    private Integer id;

    @ApiModelProperty(value = "消息类型，字典：am_msg_type")
    @Column(name = "msg_type", columnDefinition = "VARCHAR(10) COMMENT '消息类型，字典：am_msg_type'")
    protected String msgType;

    @ApiModelProperty(value = "发送人")
    @Column(name = "msg_sender", columnDefinition = "VARCHAR(200) COMMENT '发送人'")
    protected String msgSender;

    @ApiModelProperty(value = "接收人（邮箱或者手机号码）")
    @Column(name = "msg_receiver", columnDefinition = "VARCHAR(200) COMMENT '接收人'")
    protected String msgReceiver;

    @ApiModelProperty(value = "接收人姓名")
    @Column(name = "msg_receiver_name", columnDefinition = "VARCHAR(100) COMMENT '接收人姓名'")
    protected String msgReceiverName;

    @ApiModelProperty(value = "标题")
    @Column(name = "msg_title", columnDefinition = "VARCHAR(50) COMMENT '标题'")
    protected String msgTitle;

    @ApiModelProperty(value = "内容")
    @Column(name = "msg_content", columnDefinition = "text COMMENT '内容'")
    protected String msgContent;

    @ApiModelProperty(value = "消息状态，字典：am_msg_status")
    @Column(name = "msg_status", columnDefinition = "VARCHAR(10) COMMENT '消息状态，字典：am_msg_status'")
    protected String msgStatus;

    @ApiModelProperty(value = "消息成功发送次数")
    @Column(name = "msg_success_num", columnDefinition = "INT(11) COMMENT '消息成功发送次数'")
    protected Integer msgSuccessNum;

    @ApiModelProperty(value = "附件路径列表")
    @Column(name = "file_path", columnDefinition = "VARCHAR(200) COMMENT '附件路径列表'")
    protected String filePath;

    @ApiModelProperty(value = "发送人")
    @Column(name = "op_operator", columnDefinition = "varchar(20) COMMENT '发送人'")
    protected String opOperator;

    @ApiModelProperty(value = "发送时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "op_time", columnDefinition = "datetime comment '发送时间 yyyy-MM-dd HH:mm:ss'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime opTime;

    @ApiModelProperty(value = "操作动作(增加、修改)")
    @Column(name = "op_action", columnDefinition = "varchar(32) COMMENT '操作动作(增加、修改)'")
    protected String opAction;

    @ApiModelProperty(value = "操作来源")
    @Column(name = "op_source", columnDefinition = "varchar(32) COMMENT '操作来源'")
    protected String opSource;
}
